﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Frogger
{
    class Car:Automobile
    {
        bool __rotation;

        public Car(Texture2D textureImage, Vector2 position,
            Point frameSize, int collisionOffset, Point currentFrame, Point sheetSize,
            Vector2 speed, string name, int scoreValue, bool rotation )
            : base(textureImage, position, frameSize, collisionOffset, currentFrame,
            sheetSize, speed, name, scoreValue)
        {
            this.__rotation = rotation;
        }

        public Car(Texture2D textureImage, Vector2 position,
            Point frameSize, int collisionOffset, Point currentFrame, Point sheetSize,
            Vector2 speed, int millisecondsPerFrame, string name,
            int scoreValue)
            : base(textureImage, position, frameSize, collisionOffset, currentFrame,
            sheetSize, speed, millisecondsPerFrame, name, scoreValue)
        {
        }
        public Car(Texture2D textureImage, Vector2 position,
            Point frameSize, int collisionOffset, Point currentFrame, Point sheetSize,
            Vector2 speed, string name, int scoreValue, float scale, bool rotation )
            : base(textureImage, position, frameSize, collisionOffset, currentFrame,
            sheetSize, speed, name, scoreValue, scale)
        {
            this.__rotation = rotation;
        }

        //Return the collision Rectangle, it is a little different from others
        public override Rectangle collisionRect
        {
            get
            {
                return new Rectangle(
                    (int)(__position.X + (__collisionOffset * __scale)),
                    (int)(__position.Y + (__collisionOffset * __scale)),
                    (int)((__frameSize.Y - (__collisionOffset )) * __scale),
                    (int)((__frameSize.X - (__collisionOffset )) * __scale)
                    );
            }
        }

        public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            //Draw the sprite
            if (this.__rotation)
            {
                spriteBatch.Draw(this.__textureImage,
                    this.__position,
                    new Rectangle(this.__currentFrame.X * this.__frameSize.X,
                        this.__currentFrame.Y * this.__frameSize.Y,
                        this.__frameSize.X, this.__frameSize.Y),
                    Color.White, 0, Vector2.Zero,
                    this.__scale, SpriteEffects.FlipHorizontally, 0);
            }
            else 
            {
                spriteBatch.Draw(this.__textureImage,
                    this.__position,
                    new Rectangle(this.__currentFrame.X * this.__frameSize.X,
                        this.__currentFrame.Y * this.__frameSize.Y,
                        this.__frameSize.X, this.__frameSize.Y),
                    Color.White, 0, Vector2.Zero,
                    this.__scale, SpriteEffects.None, 0);
            }
        }

    }
}
